package com.acce.product.controller;

import java.io.Serializable;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.acce.base.controller.BaseController;
import com.acce.base.pojo.ArgsPojo;
import com.acce.base.pojo.ReturnPojo;
import com.acce.product.config.ErrorCodes;
import com.acce.product.config.ServiceConfig;
import com.acce.product.service.BuyGoodsService;
import com.acce.product.service.GoodsService;
import com.acce.product.service.InquiryListService;
import com.acce.product.service.PurchaseListService;
import com.acce.product.service.QuoteListService;
import com.acce.product.utils.EncodingTool;
import com.acce.product.utils.TokenUtils;
import com.acce.system.config.ReturnCodes;
import com.acce.system.pojo.LoginLog;
import com.acce.system.service.ILogService;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;

/** 
 * @ClassName: CenterController 
 * @Description: 公共访问服务类
 * @author mahuang
 * @date 2016年7月18日 下午1:46:20 
 *  
 */
@Controller
public class ProductController extends BaseController implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5941520352077835648L;
	
	private Logger logger = Logger.getLogger(ProductController.class);
	
	@Resource
	GoodsService goodsService;
	
	@Resource
	BuyGoodsService buyGoodsService;
	
	@Resource
	PurchaseListService purchaseListService;
	
	@Resource
	InquiryListService inquiryListService;
	
	@Resource
	QuoteListService quoteListService;
	
	@Resource
	private ILogService logService;

	@RequestMapping("/api/product/centerService")
	public void center(@ModelAttribute("argsPojo")ArgsPojo args,HttpServletRequest request, HttpServletResponse response){
		response.setCharacterEncoding("UTF-8");
		ReturnPojo rp = new ReturnPojo();
		JSONObject jb = null;
		try {
			jb = (JSONObject)JSONObject.toJSON(args);
		} catch(Exception ex) {
			if(jb == null) {
				rp.setServiceCode(ReturnCodes.PARAM_NULL.getCode());
				rp.setReturnCode(ReturnCodes.PARAM_NULL.getMessage());
				rp.setReturnMsg("nsy-product::center requested args format failure.");
				return;
			}
		}
		logger.info("nsy-product::center request from remote:\n" + "\t\t" + jb.toJSONString());
		
		rp.setServiceCode(args.getServiceCode());
		String business = EncodingTool.encodeStr(args.getBusiness());
		logger.info("business: " + business);
		args.setBusiness(business);
		rp = doService(args);
		String json = "";
		if(rp != null) {
			jb = (JSONObject) JSONObject.toJSON(rp);
			json = JSONObject.toJSONString(jb, SerializerFeature.WriteMapNullValue);
		}
		writeJsonToResponse(response, json);
	}
	
	private ReturnPojo doService(ArgsPojo args) {
		ReturnPojo rp = new ReturnPojo();
		rp.setServiceCode(args.getServiceCode());
		rp.setReturnCode(ReturnCodes.PARAM_NULL.getCode());
		rp.setReturnMsg(ReturnCodes.PARAM_NULL.getMessage());
		logger.info("nsy-product::doService serviceCode:" + args.getServiceCode());

		if(!isEmptyHead(args)) {
			return rp;
		}

		if(ServiceConfig.findYXGoods.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				logger.info("nsy-product:: business - " + business);
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null 
					|| StringUtils.isEmpty(jb.getString("atUserId"))
//					|| StringUtils.isEmpty(jb.getString("goodsKingdom"))
					) {
					logger.info("nsy-product:doService::find goods missing args: [atUserId]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				if(sign.equals(args.getSign())) {
					logger.info("token passed!");
					rp = goodsService.findYXGoods(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.query_goods_failure.getCode());
				rp.setReturnMsg(ErrorCodes.query_goods_failure.getMessage());
			}
		}
		
		if(ServiceConfig.createYXGoods.getServiceCode().equals(args.getServiceCode())) {
			//String atUserId = null;
			//List<BuyGoods> list = null;
			JSONObject jb = null;
			try {
				String business = args.getBusiness();
				jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| (jb.getJSONObject("goods") == null)
				) {
					logger.info("nsy-product:doService::create goods missing args: [atUserId, goods");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!", ex);
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = goodsService.insertYXGoods(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.add_goods_failure.getCode());
				rp.setReturnMsg(ErrorCodes.add_goods_failure.getMessage());
				
			}
		}
		
		if(ServiceConfig.deleteYXGoods.getServiceCode().equals(args.getServiceCode())) {
			JSONObject jb = null;
			try {
				String business = args.getBusiness();
				jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
						|| (jb.getJSONObject("goods") == null)
						) {
					logger.info("nsy-product:doService::delete goods missing args: [atUserId, goods");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!", ex);
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = goodsService.updateYXGoods(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.update_goods_failure.getCode());
				rp.setReturnMsg(ErrorCodes.update_goods_failure.getMessage());
				
			}
		}
		
		if(ServiceConfig.employee.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				logger.info("nsy-product:: business - " + business);
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null 
					|| StringUtils.isEmpty(jb.getString("atUserId"))
					|| StringUtils.isEmpty(jb.getString("companyId"))) {
					logger.info("nsy-product:doService::employee access missing args: [atUserId, companyId]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				if(sign.equals(args.getSign())) {
					logger.info("token passed!");
					rp = buyGoodsService.findBuyGoods(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.query_goods_failure.getCode());
				rp.setReturnMsg(ErrorCodes.query_goods_failure.getMessage());
			}
		}
		
		if(ServiceConfig.createCommodity.getServiceCode().equals(args.getServiceCode())) {
			//String atUserId = null;
			//List<BuyGoods> list = null;
			JSONObject jb = null;
			try {
				String business = args.getBusiness();
				jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| (jb.getJSONObject("create") == null)
					&& (jb.getJSONObject("update") == null)
						) {
					logger.info("nsy-product:doService::create commodity missing args: [atUserId, {(create,update)+}");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!", ex);
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = buyGoodsService.updateBuyGoods(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				if(jb != null && jb.getJSONObject("create") != null) {
					rp.setReturnCode(ErrorCodes.add_goods_failure.getCode());
					rp.setReturnMsg(ErrorCodes.add_goods_failure.getMessage());
				}
				if(jb != null && jb.getJSONObject("update") != null) {
					rp.setReturnCode(ErrorCodes.update_goods_failure.getCode());
					rp.setReturnMsg(ErrorCodes.update_goods_failure.getMessage());
				}
			}
		}
		
		if(ServiceConfig.createBuyGoods.getServiceCode().equals(args.getServiceCode())) {
			//String atUserId = null;
			//List<BuyGoods> list = null;
			try {
				String business = args.getBusiness();
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| (jb.getJSONArray("update") != null)
					) {
					logger.info("nsy-product:doService::create buy goods missing args: [atUserId, update[{..},{..}..]]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = buyGoodsService.updateBuyGoods(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.create_buylist.getCode());
				rp.setReturnMsg(ErrorCodes.create_buylist.getMessage());
			}
		}
		
		if(ServiceConfig.createPuchaseList.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
						|| (jb.getJSONObject("purchaseHeader") == null)
						|| (jb.getJSONArray("purchaseList") == null)
					) {
					logger.info("nsy-product:doService::create purchase list  missing args: [atUserId, purchaseHeader, purchaseList]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = purchaseListService.insertPurchaseList(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.create_purchase_failure.getCode());
				rp.setReturnMsg(ErrorCodes.create_purchase_failure.getMessage());
			}
		}
		
		if(ServiceConfig.updatePuchaseList.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| (jb.getJSONObject("purchaseHeader") == null)
					&& (jb.getJSONArray("purchaseList") == null)
					) {
					logger.info("nsy-product:doService::update purchase list  missing args: [atUserId, purchaseHeader, purchaseList]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = purchaseListService.updatePurchaseList(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.update_purchase_failure.getCode());
				rp.setReturnMsg(ErrorCodes.update_purchase_failure.getMessage());
			}
		}
		
		if(ServiceConfig.findPuchaseHeader.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| StringUtils.isEmpty(jb.getString("sendCompanyId"))
					//|| StringUtils.isEmpty(jb.getString("createTime"))
					//|| StringUtils.isEmpty(jb.getString("direction"))
					|| StringUtils.isEmpty(jb.getString("count"))
					) {
					logger.info("nsy-product:doService::find purchase header missing args: [atUserId, sendCompanyId, createTime?, direction?, count]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = purchaseListService.findPurchaseHeader(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.query_purchaseheader_failure.getCode());
				rp.setReturnMsg(ErrorCodes.query_purchaseheader_failure.getMessage());
			}
		}
		
		if(ServiceConfig.findPuchaseList.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| StringUtils.isEmpty(jb.getString("frontId"))
					) {
					logger.info("nsy-product:doService::find purchase list missing args: [atUserId, frontId]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = purchaseListService.findPurchaseList(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.query_purchaselist_failure.getCode());
				rp.setReturnMsg(ErrorCodes.query_purchaselist_failure.getMessage());
			}
		}
		
		if(ServiceConfig.deletePuchaseList.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| StringUtils.isEmpty(jb.getString("frontId"))
					) {
					logger.info("nsy-product:doService::delete purchase list missing args: [atUserId, frontId]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				logger.info("token: " + token + ", sign: " + sign);
				logger.info("args sign : " + args.getSign());
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = purchaseListService.deletePurchaseList(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.delete_purchase_failure.getCode());
				rp.setReturnMsg(ErrorCodes.delete_purchase_failure.getMessage());
			}
		}
		
		if(ServiceConfig.createInquiryList.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| (jb.get("channels") == null)
					|| (jb.get("purchaseHeader") == null)
					) {
					logger.info("nsy-product:doService::create inquirylist missing args: [atUserId, channels, purchaseHeader]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				logger.info("token: " + token + ", sign: " + sign);
				logger.info("args sign : " + args.getSign());
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = inquiryListService.insertInquiryList(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.create_inquiry_failure.getCode());
				rp.setReturnMsg(ErrorCodes.create_inquiry_failure.getMessage());
			}
		}
		
		if(ServiceConfig.createDirInqList.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| (jb.get("channels") == null)
					|| (jb.get("purchaseHeader") == null)
					|| (jb.get("purchaseList") == null)
					) {
					logger.info("nsy-product:doService::create inquirylist missing args: [atUserId, channels, purchaseHeader, purchaseList]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				logger.info("token: " + token + ", sign: " + sign);
				logger.info("args sign : " + args.getSign());
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = inquiryListService.insertDirInqList(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.create_dirinq_failure.getCode());
				rp.setReturnMsg(ErrorCodes.create_dirinq_failure.getMessage());
			}
		}
		
		if(ServiceConfig.findInquiryHeader.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| StringUtils.isEmpty(jb.getString("sendCompanyId"))
					//|| StringUtils.isEmpty(jb.getString("createTime"))
					//|| StringUtils.isEmpty(jb.getString("direction"))
					|| StringUtils.isEmpty(jb.getString("count"))
					) {
					logger.info("nsy-product:doService::find inquiry header missing args: [atUserId, sendCompanyId, createTime?, direction?, count]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				logger.info("token: " + token + ", sign: " + sign);
				logger.info("args sign : " + args.getSign());
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = inquiryListService.findInquiryHeader(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.query_inquiryheader_failure.getCode());
				rp.setReturnMsg(ErrorCodes.query_inquiryheader_failure.getMessage());
			}
		}
		
		if(ServiceConfig.findInquiryList.getServiceCode().equals(args.getServiceCode())
			|| ServiceConfig.findChaInqList.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| StringUtils.isEmpty(jb.getString("frontId"))
					) {
					logger.info("nsy-product:doService::find inquiry list missing args: [atUserId, frontId]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				logger.info("token: " + token + ", sign: " + sign);
				logger.info("args sign : " + args.getSign());
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = inquiryListService.findInquiryList(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				if(ServiceConfig.findInquiryList.getServiceCode().equals(args.getServiceCode())) {
					rp.setReturnCode(ErrorCodes.query_inquirylist_failure.getCode());
					rp.setReturnMsg(ErrorCodes.query_inquirylist_failure.getMessage());
				} else {
					rp.setReturnCode(ErrorCodes.query_chainqlist_failure.getCode());
					rp.setReturnMsg(ErrorCodes.query_chainqlist_failure.getMessage());
				}
			}
		}
		
		if(ServiceConfig.findChaInqHeader.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| StringUtils.isEmpty(jb.getString("recCompanyId"))
					//|| StringUtils.isEmpty(jb.getString("createTime"))
					//|| StringUtils.isEmpty(jb.getString("direction"))
					|| StringUtils.isEmpty(jb.getString("count"))
					) {
					logger.info("nsy-product:doService::find channel inquiry header missing args: [atUserId, recCompanyId, createTime?, direction?, count]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				logger.info("token: " + token + ", sign: " + sign);
				logger.info("args sign : " + args.getSign());
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = inquiryListService.findChaInqHeader(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.query_chainqheader_failure.getCode());
				rp.setReturnMsg(ErrorCodes.query_chainqheader_failure.getMessage());
			}
		}
		
		if(ServiceConfig.deleteInqList.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| StringUtils.isEmpty(jb.getString("frontId"))
					) {
					logger.info("nsy-product:doService::delete inquiry list missing args: [atUserId, frontId]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				logger.info("token: " + token + ", sign: " + sign);
				logger.info("args sign : " + args.getSign());
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = inquiryListService.deleteInquiryList(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.delete_inquiry_failure.getCode());
				rp.setReturnMsg(ErrorCodes.delete_inquiry_failure.getMessage());
			}
		}
		
		//创建报价单
		if(ServiceConfig.createQuoteList.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| (jb.getString("frontId") == null)
					|| (jb.get("inquiryList") == null)
					) {
					logger.info("nsy-product:doService::create quote list missing args: [atUserId, inquiryHeader, inquiryList]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				logger.info("token: " + token + ", sign: " + sign);
				logger.info("args sign : " + args.getSign());
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = quoteListService.insertQuoteList(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.create_quote_failure.getCode());
				rp.setReturnMsg(ErrorCodes.create_quote_failure.getMessage());
			}
		}
		
		//渠道商查询报价单
		if(ServiceConfig.findQuoteHeader.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| StringUtils.isEmpty(jb.getString("sendCompanyId"))
					//|| StringUtils.isEmpty(jb.getString("createTime"))
					//|| StringUtils.isEmpty(jb.getString("direction"))
					|| StringUtils.isEmpty(jb.getString("count"))
					) {
					logger.info("nsy-product:doService::find channel quote header missing args: [atUserId, sendCompanyId, createTime?, direction?, count]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				logger.info("token: " + token + ", sign: " + sign);
				logger.info("args sign : " + args.getSign());
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = quoteListService.findChaQuoteHeader(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.query_chaquoheader_failure.getCode());
				rp.setReturnMsg(ErrorCodes.query_chaquoheader_failure.getMessage());
			}
		}
		
		//查询报价清单信息
		if(ServiceConfig.findQuoteList.getServiceCode().equals(args.getServiceCode())
			|| ServiceConfig.findQuoList.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| StringUtils.isEmpty(jb.getString("frontId"))
					) {
					logger.info("nsy-product:doService::find quote list missing args: [atUserId, frontId]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				logger.info("token: " + token + ", sign: " + sign);
				logger.info("args sign : " + args.getSign());
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = quoteListService.findQuoteList(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				if(ServiceConfig.findQuoteList.getServiceCode().equals(args.getServiceCode())) {
					rp.setReturnCode(ErrorCodes.query_chaquolist_failure.getCode());
					rp.setReturnMsg(ErrorCodes.query_chaquolist_failure.getMessage());
				} else {
					rp.setReturnCode(ErrorCodes.query_quotelist_failure.getCode());
					rp.setReturnMsg(ErrorCodes.query_quotelist_failure.getMessage());
				}
			}
		}
		
		//采购商查询接收到的报价单
		if(ServiceConfig.findQuoHeader.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| StringUtils.isEmpty(jb.getString("recCompanyId"))
					//|| StringUtils.isEmpty(jb.getString("createTime"))
					//|| StringUtils.isEmpty(jb.getString("direction"))
					|| StringUtils.isEmpty(jb.getString("count"))
					) {
					logger.info("nsy-product:doService::find quote header missing args: [atUserId, recCompanyId, createTime?, direction?, count]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				logger.info("token: " + token + ", sign: " + sign);
				logger.info("args sign : " + args.getSign());
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = quoteListService.findQuoteHeader(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.query_quoteheader_failure.getCode());
				rp.setReturnMsg(ErrorCodes.query_quoteheader_failure.getMessage());
			}
		}
		
		//删除报价单
		if(ServiceConfig.deleteQuoList.getServiceCode().equals(args.getServiceCode())) {
			try {
				String business = args.getBusiness();
				JSONObject jb = (JSONObject)JSONObject.parse(business);
				if(jb == null) {
					return rp;
				}
				if(StringUtils.isEmpty(jb.getString("atUserId"))
					|| StringUtils.isEmpty(jb.getString("frontId"))
					) {
					logger.info("nsy-product:doService::delete quote list missing args: [atUserId, frontId]");
					return rp;
				}
			} catch(Exception ex) {
				logger.error("args error!");
				return rp;
			}
			ReturnPojo rpLogin = logService.loadToken(args);
			String recode = rpLogin.getReturnCode();
			LoginLog loginLog = JSONObject.parseObject(JSONObject.toJSONString(rpLogin.getResult()), LoginLog.class);
			if(!"200".equals(recode)){
				rp.setReturnCode(rpLogin.getReturnCode());
				rp.setReturnMsg(rpLogin.getReturnMsg());
				return rp;
			}
			String token = loginLog.getToken();
			if(StringUtils.isEmpty(token)){
				rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
				rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
				return rp;
			}
			String sign = null;
			try {
				sign = TokenUtils.getSign(token, args.getTimestamp(), args.getNonce());
				logger.info("check token if is available?");
				logger.info("token: " + token + ", sign: " + sign);
				logger.info("args sign : " + args.getSign());
				if(sign.equals(args.getSign())){
					logger.info("token passed!");
					rp = quoteListService.deleteQuoteList(args);
				} else {
					rp.setReturnCode(ReturnCodes.SIGN_VALID_FAIL.getCode());
					rp.setReturnMsg(ReturnCodes.SIGN_VALID_FAIL.getMessage());
					logger.info("abort, token does not match!");
				}
			} catch(Exception e){
				logger.error("request failure!", e);
				rp.setReturnCode(ErrorCodes.delete_quote_failure.getCode());
				rp.setReturnMsg(ErrorCodes.delete_quote_failure.getMessage());
			}
		}
		
		return rp;
	}
	
}
